package com.treasure.service.collocate.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.collocate.service.ArticleService;
import com.treasure.service.collocate.service.BankConfigService;
import com.treasure.service.dto.TArticleDto;
import com.treasure.service.dto.TBankConfigDto;
import com.treasure.service.enums.CodeEnum;
import com.treasure.service.result.PageResult;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 获取资讯信息
 * @version 1.0
 * @author panxinwen 2018/10/30 10:32
 * @Copyright © 2015 | 武汉京航科技有限公司 Email:19919866605@163.com
 * */
@Api(value = "资讯，文章信息维护",description = "资讯，文章信息维护")
@RestController
@RequestMapping("/article/v1")
public class ArticleController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ArticleService articleService;


    @ApiOperation(value = "获取资讯列表", notes = "获取资讯列表")
    @PostMapping("/getArticleList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "頁碼", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每頁顯示數量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "当前状态(0-禁用 1-启用)", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "recommend", value = "是否首页展示(0-否 1-是)", required = true, dataType = "int", paramType = "query"),
    })
    @LogInfo(log = "获取资讯列表",isPrint = true)
    public ResponseEntity<ResponseResult> getArticleList(@RequestParam(value = "pageSize") Integer pageSize,
                                         @RequestParam(value = "pageNum") Integer pageNum,
                                         @RequestParam(value = "status",required = false) Integer status,
                                         @RequestParam(value = "recommend",required = false) Integer recommend
    ){

        PageResult<List<TArticleDto>> result = articleService.getArticleList(pageSize,pageNum,status,recommend);

        return ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,result));

    }
    @ApiOperation(value = "获取通知", notes = "消息通知，当有最新的动态(出现返佣时放入缓存，前端每次刷新页面显示最新的指定条数)")
    @PostMapping("/getNoticeList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每頁顯示數量", required = true, dataType = "int", paramType = "query")
    })
    @LogInfo(log = "获取资讯列表",isPrint = true)
    public ResponseEntity<ResponseResult> getNoticeList(@RequestParam(value = "pageSize") Long pageSize
    ){

        List<String> result = articleService.getNoticeList(pageSize);

        return ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,result));

    }



}
